package com.djt.book_system.controller;

import com.djt.book_system.dao.LoginDao;
import com.djt.book_system.entity.Users;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("test")
@RestController
public class TestController {
    @Resource
    private LoginDao loginDao;
    @PostMapping("login")
    public Users login(Users users){
        Users users1 = loginDao.selectUser(users.getUname());
        if (users1 != null && users.getUpwd().equals(users1.getUpwd()) && users1.getEnable()==1){
            users1.setAid(loginDao.selectAidByUid(users1.getUid()));
            loginDao.loginLogs(users1.getUid());
            return users1;

        }
        return null;
    }
}
